package com.sq.shortlink.admin.remoto;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sq.shortlink.admin.common.convension.result.Result;
import com.sq.shortlink.admin.remoto.dto.req.RecycleBinRecoverReqDTO;
import com.sq.shortlink.admin.remoto.dto.req.RecycleBinRemoveDTO;
import com.sq.shortlink.admin.remoto.dto.req.RecycleBinSaveReqDTO;
import com.sq.shortlink.admin.remoto.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.sq.shortlink.admin.remoto.dto.resp.ShortLinkPageRespDTO;

import java.util.HashMap;
import java.util.Map;

/**
 * 回收站管理接口层
 * @author quan
 */
public interface RecycleBinRemoteService {
    default Result<IPage<ShortLinkPageRespDTO>> pageRecycleBinShortLink(ShortLinkRecycleBinPageReqDTO requestParam) {
        Map<String,Object> map = new HashMap<>();
        map.put("gidList",requestParam.getGidList());
        map.put("current",requestParam.getCurrent());
        map.put("size",requestParam.getSize());
        String resultBodyStr = HttpUtil.post("http://localhost:8001/api/short-link/v1/recycle-bin/page", JSON.toJSONString(map));
        return JSON.parseObject(resultBodyStr, new TypeReference<>() {
        });
    }

    default Result<Void> saveRecycleBin(RecycleBinSaveReqDTO requestParam){
        String resultBodyStr = HttpUtil.post("http://localhost:8001/api/short-link/v1/recycle-bin/save", JSON.toJSONString(requestParam));
        return JSON.parseObject(resultBodyStr, new TypeReference<>() {
        });
    }

    default Result<Void> recycleBinRecover(RecycleBinRecoverReqDTO requestParam){
        String resultBodyStr = HttpUtil.post("http://localhost:8001/api/short-link/v1/recycle-bin/recover", JSON.toJSONString(requestParam));
        return JSON.parseObject(resultBodyStr, new TypeReference<>() {
        });
    }

    default Result<Void> recycleBinRemove(RecycleBinRemoveDTO requestParam){
        String resultBodyStr = HttpUtil.post("http://localhost:8001/api/short-link/v1/recycle-bin/remove", JSON.toJSONString(requestParam));
        return JSON.parseObject(resultBodyStr, new TypeReference<>() {
        });
    }
}
